//
//  DcNAlubmButton.m
//  Decathlon
//
//  Created on 14-11-4.
//  Copyright (c) 2014年. All rights reserved.
//

#import "RCSAlubmButton.h"

@interface RCSAlubmButton()

@property (nonatomic, strong) UIImageView *icon;
@property (nonatomic, strong) UILabel *videoLab;

@end

@implementation RCSAlubmButton

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
    }
    return self;
}

-(id)init
{
    if (self = [super init])
    {
        _maskLayer = [[UIView alloc] initWithFrame:self.bounds];
        _maskLayer.layer.cornerRadius = 3;
        _maskLayer.tag = 5555;
        _maskLayer.hidden = YES;
		_maskLayer.backgroundColor = RGBA(255, 255, 255, 0.8);
        [self addSubview:_maskLayer];
    }
    return self;
}

-(void)setShowMaskLayer:(BOOL)show
{
    if (show)
    {
        _maskLayer.hidden = NO;
        _maskLayer.frame = self.bounds;
    }
    else
    {
        _maskLayer.hidden = YES;
    }
}

-(void)setVideoIcon:(UIImage *)image videoTime:(NSString *)videoTimeStr
{
    NSInteger iconHeigtht = 20;
    NSInteger labWidth = 60;
    
    if (!self.icon)
    {
        self.icon = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - iconHeigtht, self.frame.size.width, iconHeigtht)];
        self.icon.image = image;
        [self addSubview:self.icon];
    }
    else
    {
        self.icon.hidden = NO;
    }
    
    if (!self.videoLab)
    {
        self.videoLab = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width -  labWidth , 0 , labWidth, iconHeigtht)];
        self.videoLab.text = videoTimeStr;
        self.videoLab.textAlignment = NSTextAlignmentRight;
        self.videoLab.textColor = [UIColor whiteColor];
        self.videoLab.font = [UIFont systemFontOfSize:11];
        self.videoLab.backgroundColor = [UIColor clearColor];
        [self.icon addSubview:self.videoLab];
        
    }
    else
    {
        self.videoLab.text = videoTimeStr;
        self.videoLab.hidden = NO;
    }
}

-(void)hideVideoView
{
    self.icon.hidden = YES;
    self.videoLab.hidden = YES;
}

@end
